package com.chuangjiangx.member.manager.client.web.basic.request.aiface;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 充值请求参数
 *
 * @author 马文韬
 * @version 1.0
 * @date: 2018/9/13
 */
@Setter
@Getter
@ApiModel(value = "充值请求参数")
public class RechargeRequest {

    @NotNull(message = "要充值的会员ID不能为空")
    @ApiModelProperty(value = "要充值的会员ID", required = true)
    private Long memberId;

    @ApiModelProperty(value = "充值规则ID", allowableValues = "-1 - 自定义充值，无规则（不传也可以）")
    private Long rechargeRuleId;

    @Min(value = 0, message = "充值金额必须大于0")
    @ApiModelProperty(value = "自定义充值金额", allowableValues = "大于0的实数")
    private BigDecimal customRechargeAmount;

    @NotEmpty(message = "付款码必须提供")
    @ApiModelProperty(value = "付款码", required = true)
    private String authCode;

    @NotNull(message = "支付类型必须传入")
    @Min(value = 0, message = "不兼容的支付类型")
    @Max(value = 1, message = "不兼容的支付类型")
    @ApiModelProperty(value = "支付类型，目前只支持 0 - 微信，1 - 支付宝",
            allowableValues = "0 - 微信，1 - 支付宝", required = true)
    private Integer payType;

    @ApiModelProperty(value = "商户自定义的扫码终端设备号", notes = "方便追溯到扫码终端")
    private String deviceInfo;


    public boolean isCustomRecharge() {
        return rechargeRuleId == null ||
                rechargeRuleId == -1;
    }

}
